'use strict'
const _const = require('../src/commons/const')
const passwordUtility = require('../src/commons/password_utility')


// 初始化数据脚本
async function main() {
    const mongoose_service = require('../src/services/mongoose')
    await mongoose_service.lift();


    const {AdminUserModel,UserModel} = require('../src/models/index')
    const username = "SSD_ADMIN";
    const password = "123456";
    await AdminUserModel.deleteMany({});
    await AdminUserModel.create([ // 初始化 后台管理系统 密码
      {
        username: username,
        password: passwordUtility.cookPw(password), //
        is_super: 2
      }
    ])

    console.log(`admin create name:${username}  pass:${password}`);
    await mongoose_service.lower()
}


main().catch((error) => {
    console.error(error)
    process.exit(1)
})

